import datetime
from models.base import *


class DataTag(TimestampMixin, OtherMixin, TenantMixin, UidMixin, BaseModel):
    name = fields.CharField(max_length=50, description="tag name")

    class Meta:
        abstract = False
        table = 'p_data_tag'
        table_description = '数据池标签'

    async def list_to_dict(self):
        request_dict = {f: getattr(self, f) for f in self._meta.fields}
        request_dict['create_ts'] = datetime.datetime.strftime(request_dict['create_ts'], '%Y-%m-%d')
        request_dict['update_ts'] = datetime.datetime.strftime(request_dict['update_ts'], '%Y-%m-%d')
        return request_dict
